/*
	MemChain.h

	Digital STREAM Technology, inc.
*/

/********************************************************************
 *
 * DHL_memchain.h - Utility for associating allocated memory
 *
 * Copyright 1997-2002 TeraLogic, Inc.
 * All Rights Reserved
 *
 * memChainCreate:     Creates a memChain object.
 *   (O) instance:     returns the memChain instance.
 *   (I) memLimit:     Optionally limits the memory allocated with a
 *                     memChain.  Set to 0xFFFFFFFF for no limit.
 *
 * memChainDestroy:    Destroys a memChain object.
 *   (I) instance:     The memChain instance.
 *
 * memChainAlloc:      Allocates a memory block and associates it with
 *                     the specified memChain object.
 *   (I) instance:     The memChain instance.
 *   (I) size:         Size of memory (in bytes) requested.  
 *
 * $Id: //suprahd/releases/suprahd_239/suprahd_zTVApp660_239/drivers/include/DHL_memchain.h#1 $
 * $Revision: #1 $
 * $DateTime: 2006/06/05 14:53:58 $
 * $Change: 45890 $
 * $Author: catherine.lee $
 * 
 ********************************************************************/

#ifndef _memchain_h
#define _memchain_h

#include "DHL_Types.h"
//#include "common.h"

//#include "TLTypesBasic.h"
//#include "TLErrors.h"


/* user-defined malloc/free */
typedef void* (*myMalloc_f) (unsigned size);
typedef void (*myFree_f) (void *block);

/* memChain Setup Info */
typedef struct memChainSetup {
	UINT32		memLimit;
	myMalloc_f		Malloc;
	myFree_f		Free;
} memChainSetup_t, *memChainSetupPtr_t;

typedef struct memChainHead* memId_t;

/* API */
ErrCode memChainCreate (memId_t *memId, memChainSetupPtr_t setupPtr);
ErrCode memChainDestroy (memId_t memId);
void* memChainAlloc (memId_t memId, UINT32 size);

#endif /* _memchain_h */
